﻿#region Using References

using System.IO;
using Beaker.OpenCube.Resources;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;

#endregion

namespace Beaker.OpenCube.Specs.Resources
{
	[TestClass]
	public class MetadataSerializionSpecs
	{
		[TestMethod]
		public void JsonDeserializeCanParseMixedFramesArray()
		{
			// arrange
			string mcmeta = "{ \"animation\": { \"frametime\": 2, \"frames\": [ { \"index\": 0, \"time\": 40 }, 1, 2 ] } }";
			var serializer = new JsonSerializer();

			// act
			var metaData = serializer.Deserialize<TextureMetadata>( new JsonTextReader( new StringReader( mcmeta ) ) );

			// assert
			metaData.Animation.Frames
				.Should().ContainInOrder(
					new[]
					{
						new TextureFrameMetadata(0,40),
						new TextureFrameMetadata(1),
						new TextureFrameMetadata(2)
					}
				);
		}
		}
}
